home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / src / Tools / MotifApp / ch2 / Stopwatch3 / Stopwatch.C < prev    next >
Encoding:
C/C++ Source or Header  |  1995-05-03  |  2.8 KB  |  104 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. //////////////////////////////////////////////////////////////////////////////
  3. //         This example code is from the book:
  4. //
  5. //           Object-Oriented Programming with C++ and OSF/Motif
  6. //         by
  7. //           Douglas Young
  8. //           Prentice Hall, 1992
  9. //           ISBN 0-13-630252-1    
  10. //
  11. //         Copyright 1991 by Prentice Hall
  12. //         All Rights Reserved
  13. //
  14. //  Permission to use, copy, modify, and distribute this software for 
  15. //  any purpose except publication and without fee is hereby granted, provided 
  16. //  that the above copyright notice appear in all copies of the software.
  17. ///////////////////////////////////////////////////////////////////////////////
  18. //////////////////////////////////////////////////////////////////////////////
  19.  
  20.  
  21. ////////////////////////////////////////////////////////////////
  22. // StopWatch.C: Group subcomponents into one stopwatch component
  23. //              Customizable, UIComponent version
  24. /////////////////////////////////////////////////////////////////
  25. #include "Stopwatch.h"
  26. #include <Xm/Xm.h>
  27. #include <Xm/RowColumn.h>
  28. #include "Timer.h"
  29. #include "Face.h"
  30. #include "Control.h"
  31.   
  32. XtResource Stopwatch::_resources [] = {
  33. {
  34.      "interval", 
  35.      "Interval", 
  36.      XmRInt, 
  37.      sizeof ( int ),
  38.      XtOffset ( Stopwatch *, _interval ), 
  39.      XmRString, 
  40.      (XtPointer) "1000",
  41.   },
  42. };
  43.  
  44. String Stopwatch::_defaults[] = {
  45.     "*face.orientation:           horizontal",
  46.     "*face*label*labelString:     Elapsed Time:",
  47.     "*face*time*labelString:      000.000",
  48.     "*face*frame*shadowType:      shadow_in",
  49.     "*control.orientation:        horizontal",
  50.     "*control.start.labelString:  Start",
  51.     "*control.stop.labelString:   Stop",
  52.      NULL,
  53.   };
  54.  
  55.  
  56. Stopwatch::Stopwatch ( Widget  parent, 
  57.                          char   *name ) :  UIComponent ( name )
  58.   {
  59.       // Load the Stopwatch default resources into the database
  60.   
  61.       setDefaultResources ( parent, _defaults );
  62.   
  63.       // Create a manager widget to hold all components
  64.   
  65.       _w = XmCreateRowColumn ( parent, _name, NULL, 0 );
  66.   
  67.       // Call UIComponent hook to set up the destruction handler
  68.   
  69.        installDestroyHandler();
  70.   
  71.       // Retrieve customizable parameters for this class
  72.   
  73.       getResources ( _resources, XtNumber ( _resources ) );
  74.   
  75.       // Create the sub-components of the stopwatch
  76.   
  77.       _face = new  Face ( _w, "face" );
  78.       _timer = new Timer ( XtWidgetToApplicationContext ( parent ), 
  79.                            _face, 
  80.                            _interval );
  81.       _control = new Control ( _w, "control", this, _timer );
  82.       _face->manage();
  83.       _control->manage();
  84.   }
  85.  
  86.  
  87. Stopwatch::~Stopwatch ( )
  88. {
  89.     delete _face;
  90.     delete _timer;
  91.     delete _control;
  92. }
  93.  
  94. void Stopwatch::timerStarted()
  95. {
  96.     // Empty
  97. }
  98.  
  99. void Stopwatch::timerStopped()
  100. {
  101.     // Empty
  102. }
  103.  
  104.